package com.yangtzeu.jwc.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.yangtzeu.jwc.app.MyApplication;
import com.yangtzeu.jwc.business.AppBusiness;
import com.yangtzeu.jwc.business.MCallBack;
import com.yangtzeu.jwc.business.UpdateBusiness;
import com.yangtzeu.jwc.business.UpdateListener;
import com.yangtzeu.jwc.domain.MyJson;
import com.yangtzeu.jwc.domain.ServerConfig;
import com.yangtzeu.jwc.utils.AllActivitys;
import com.yangtzeu.jwc.utils.Common;
import com.yangtzeu.jwc.utils.G;
import com.zhangdi.jwc.R;
import com.zjsx.lib.ui.numberprogressbar.NumberProgressBar;
import com.zjsx.lib.utils.DataUtil;
import com.zjsx.lib.utils.L;
import com.zjsx.lib.utils.PrefUtil;
import com.zjsx.lib.utils.SysInfo;

/**
 * 启动界面
 *
 * @author ZhangDI
 */
public class FullscreenActivity extends Activity implements OnClickListener {
    private ImageView startLogo;
    private Button entry_agin;
    private TextView version;
    public Handler handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case 0:
                    go();
                    break;

                default:
                    break;
            }
        }

    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        AllActivitys.getInstance().addActivity(this);
        super.onCreate(savedInstanceState);
        handler.sendEmptyMessageDelayed(0, 2000);
        setView();
        initView();
        initListener();
    }

    public void setView() {
        setContentView(R.layout.activity_fullscreen2);
    }

    public void initView() {
        startLogo = (ImageView) findViewById(R.id.fullscreen_content);
        entry_agin = (Button) findViewById(R.id.entry_agin);
        version = (TextView) findViewById(R.id.tv_version);
        version.setText("v " + SysInfo.getVersion(this));
    }

    public void initListener() {
        entry_agin.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.entry_agin:
                entry_agin.setVisibility(View.GONE);
                go();
                break;
            default:
                break;
        }
    }

    private void go() {
        if (Common.getNetIsAvailable(getApplicationContext())) {
            Intent intent = new Intent();
            intent.setClass(getApplicationContext(), MainActivity3.class);
            startActivity(intent);
            finish();
        } else {
            entry_agin.setVisibility(View.VISIBLE);
            MyApplication.getInstance().showShortToast("网络没有连接,请先设置网络!");
        }
    }
}
